import NodeRSA from 'node-rsa'

export function RSAEncrypt (pas) {
  const publicKey =
    '-----BEGIN RSA PUBLIC KEY-----\n' +
    'MIIBCgKCAQEAgBNzJ2FWbgqU/O4GgHEHeR2VkxK6ImNuFI7NwzgQVki4XWcFETux\n' +
    'FBJWB+qDk+psM7Vz0zOqGrl3vCF9CkFOmZKZekNe0R5URfzute95VvzD0KSMYilC\n' +
    'DeCLCTtqVIouVOT6IesYYp4sjH3gRTcUXrKA1BuFExVy4PpheGkvK9XE6bMFyQn/\n' +
    'cJkghSC1h6vHbc5rWu6BWJYJ8PxiXALe1mrynzbhc6x/pEPEHNcQRpzI6wQIB0d7\n' +
    'rA0HtEBDShAxGlJqdvBrZInD3obRYHdh001WijE6YXFmM1LStO5FQuFfS7iNS5Gj\n' +
    'KJd8DdMxheUFmOkrl8FuP34Zi6+ROMck1QIDAQAB\n' +
    '-----END RSA PUBLIC KEY-----\n'

  const key = new NodeRSA(publicKey)
  key.setOptions({ encryptionScheme: 'pkcs1' })
  return key.encrypt(pas, 'base64', 'utf8')
}
